<template>
	<div>
		<qf-image-cropper :width="500" :height="500" :radius="30" @crop="handleCrop" :src="src"></qf-image-cropper>
	</div>
</template>

<script>
export default {
	data() {
		return {
			src: '',
			baseUrl: ''
		};
	},
	onLoad({ src }) {
		this.src = src;
	},
	methods: {
		handleCrop(e) {
			// uni.previewImage({
			//     urls: [e.tempFilePath],
			//     current: 0
			// });
			this.uploadImage(e.tempFilePath);
		},
		uploadImage(tempFilePaths) {
			this.$http
				.upload(this.$config.UrlSignUpload, {
					filePath: tempFilePaths,
					name: 'file',
					formData: {}
				})
				.then(res => {
					if (res.code == 1) {
						uni.$emit('upload', res.data.url);
						uni.navigateBack();
					} else this.$api.toast(res.msg);
				});
		}
	}
};
</script>
